
import { router } from "./routers";

Bun.serve({

    port: 3000,

    static: {

        "/": new Response("welcome to my website"),

        //@ts-ignore
        "/authorInfo": new Response(JSON.stringify(global.authorInfo)),

    },

    fetch(req) {

        return router.exe(req);

    },

});

const socket = await Bun.udpSocket({
    port: 41234,
    socket: {
        data(socket, buf, port, addr) {
            console.log(`message from ${addr}:${port}:`);
            console.log(buf.toString());
        },

    }
});

const server = await Bun.udpSocket({
    port: 41235,
    socket: {
        data(socket, buf, port, addr) {
            console.log(`message from ${addr}:${port}:`);
            console.log(buf.toString());
        }
    }
});

const client = await Bun.udpSocket({
    port: 52000
});


client.send("Hello!", server.port, "127.0.0.1");
socket.send("Hello, world!", 41234, "127.0.0.1");
